package com.ehome.plugin

import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import java.io.File
import java.lang.IllegalStateException

abstract class VerifyAssetTask : DefaultTask() {

    @get:OutputDirectory
    abstract val output:DirectoryProperty

    @get:InputDirectory
    @get:Optional
    abstract val assets:DirectoryProperty

    @TaskAction
    fun taskAction(){
        File(assets.get().asFile, "custom_asset.txt").let {
            if (it.exists()){
                println("Fount ${it} in merged assets folder")
            }else{
                throw IllegalStateException("custom_asset.txt file not present in merged asset folder: ${assets.get().asFile}")
            }
        }
    }
}

